﻿using AutoMapper;
using MediatR;
using SheepStorage.API.Application.Command.SheepChangeDormCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.SheepChangeDormHandler
{
	public class ChangeDormDeleteHandler : IRequestHandler<ChangeDormDeleteCommand, Results<int>>
	{

		/// </summary>

		private readonly IChangeDormitoryService service;
		/// <summary>
		/// AutoMapper
		/// </summary>
		private readonly IMapper mapper;

		public ChangeDormDeleteHandler(IChangeDormitoryService service, IMapper mapper)
		{
			this.service = service;
			this.mapper = mapper;
		}


		public async Task<Results<int>> Handle(ChangeDormDeleteCommand request, CancellationToken cancellationToken)
		{
			//throw new NotImplementedException();
			var res = await service.DeleteChangeDormitory(request.ChangeId);

			return Results<int>.DataResult(res);

		}
	}
}
